/**
 * 员工组件展示界面
 * @author SPY
 * @date 2020/04/08
 */

import React from 'react';
import { Form, Row, Col, Alert, Button } from 'antd';
import { Link } from 'umi';
import DeptTree from '@/components/Tree/DeptTree/DeptTree';

const targetKeys: any = [];
const mockData: any = [];
for (let i = 0; i < 20; i++) {
  const data = {
    key: i.toString(),
    title: `content${i + 1}`,
    description: `description of content${i + 1}`,
    chosen: Math.random() * 2 > 1,
  };
  if (data.chosen) {
    targetKeys.push(data.key);
  }
  mockData.push(data);
}

const treeData = [
  {
    key: '1',
    title: '集团总部',
    children: [
      {
        key: '11',
        title: '集团总部-人事部',
        isLeaf: true,
      },
      {
        key: '12',
        title: '集团总部-开发部',
        isLeaf: true,
      },
    ],
  },
  {
    key: '2',
    title: '上海分公司',
    isLeaf: true,
  },
];

export default () => {
  const renderMessage = () => {
    return (
      <span>
        注意：该页面的仅展示员工组件,无数据交互！
        <Link to="/antd/form">
          <Button type="link">查看实例</Button>
        </Link>
      </span>
    );
  };

  return (
    <Form layout="vertical" initialValues={{ personalIn: ['1', '2'] }}>
      <Alert message={renderMessage()} />
      <Row gutter={24}>
        <Col span={8}>
          <DeptTree
            treeDataSource={treeData}
            transferDataSource={[]}
            // handleTransferChange={handleTransferChange}
            transferIdKey="id"
            transferNameKey="name"
            transferLimitMaxCount={1}
            transferShowPersonalList={[]}
            label="上级领导(仅能选一人)"
            name="leader"
          />
        </Col>
        <Col span={8}>
          <DeptTree
            treeDataSource={treeData}
            transferDataSource={[]}
            // handleTransferChange={handleTransferChange}
            transferIdKey="id"
            transferNameKey="name"
            transferLimitMaxCount={0}
            transferShowPersonalList={[]}
            label="优秀员工(人数不限制)"
            name="personal"
          />
        </Col>
        <Col span={8}>
          <DeptTree
            treeDataSource={treeData}
            transferDataSource={[]}
            // handleTransferChange={handleTransferChange}
            transferIdKey="id"
            transferNameKey="name"
            transferLimitMaxCount={0}
            transferShowPersonalList={[]}
            label="入职员工(填充默认员工)"
            name="personalIn"
          />
        </Col>
      </Row>
    </Form>
  );
};
